#include "log.h"

#if DBG
#include <sys/time.h>
void print_data(const char *msg, const void *data, ssize_t datalen)
{
    if (datalen <= 0)
        return;
    struct timeval tv;
    struct timezone tz;
    gettimeofday(&tv, &tz);
    tv.tv_sec -= tz.tz_minuteswest * 60;
    int s = tv.tv_sec % 60;
    int m = tv.tv_sec / 60 % 60;
    int h = tv.tv_sec / 3600 % 24;
    fprintf(stdout, "%02d:%02d:%02d.%06lu: %s: ", h, m, s, tv.tv_usec, msg);
    while (datalen--)
        fprintf(stdout, "%02hhX ", *(unsigned char *) data++);
    fprintf(stdout, "\n");
}
#endif
